package com.meta.nd.controller;


import com.meta.common.CommonInfo;
import com.meta.nd.filter.vo.FilterByDefVo;
import com.meta.nd.filter.vo.FilterResultVo;
import com.meta.nd.service.NvFilterService;
import com.meta.nd.vo.*;
import com.meta.util.ExceptionUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
public class NvFilterController {
	@Resource
	NvFilterService nvFilterService;
	@RequestMapping(value = "/nv/filter/filterNvsByDef", method = RequestMethod.POST)
	public  ReturnMessage<FilterResultVo> filterNvsByDef(@RequestBody RequestMessage<FilterByDefVo> requestMessage) {
		CommonInfo commonInfo = requestMessage.getCommonInfo();
		try{
			FilterResultVo result = nvFilterService.filterNvs(commonInfo,requestMessage.getValue());
			return new ReturnMessage<FilterResultVo>(result,true);
		}catch (Exception e ){
			log.error(e.getMessage(),e);
			return new ExceptionUtils().buildReturnMessage(e);
		}
	}
}
